import mieRequest from "@/service";
import { ElNotification } from "element-plus";
////页面通用请求数据
//获取页面content数据
export function getPageListData(url: string, queryInfo: any) {
  return mieRequest.post({
    url: url,
    data: queryInfo,
  });
}
// 删除单个用户数据
export function deletePageData(url: string) {
  return mieRequest.delete({
    url: url,
    interceptors: {
      responseSuccessFn: (res) => {
        if (res.code) {
          ElNotification({
            message: res.msg,
            type: "success",
          });
        } else {
          ElNotification({
            message: res.msg,
            type: "warning",
          });
        }
      },
    },
  });
}
// 新建一个数据
export function createPageData(url: string, userInfo: any) {
  console.log(userInfo);
  return mieRequest.post({
    url: url,
    data: userInfo,
    interceptors: {
      responseSuccessFn: (res) => {
        if (res.code) {
          ElNotification({
            message: res.msg,
            type: "success",
          });
        } else {
          ElNotification({
            message: res.msg,
            type: "warning",
          });
        }
      },
    },
  });
}
// 编辑一个数据
export function editPageData(url: string, userInfo: any) {
  return mieRequest.patch({
    url: url,
    data: userInfo,
    interceptors: {
      responseSuccessFn: (res) => {
        if (res.code) {
          ElNotification({
            message: res.msg,
            type: "success",
          });
        } else {
          ElNotification({
            message: res.msg,
            type: "warning",
          });
        }
      },
    },
  });
}
